#include <stdio.h>

// 合并两个数组并排序
void mergeAndSort(int arr1[], int size1, int arr2[], int size2)
{
  int merged[size1 + size2];
  for (int i = 0; i < size1; i++)
  {
    merged[i] = arr1[i];
  }
  for (int i = 0; i < size2; i++)
  {
    merged[size1 + i] = arr2[i];
  }

  // 冒泡排序
  for (int i = 0; i < size1 + size2 - 1; i++)
  {
    for (int j = 0; j < size1 + size2 - i - 1; j++)
    {
      if (merged[j] > merged[j + 1])
      {
        int temp = merged[j];
        merged[j] = merged[j + 1];
        merged[j + 1] = temp;
      }
    }
  }

  printf("Merged and sorted array: ");
  for (int i = 0; i < size1 + size2; i++)
  {
    printf("%d ", merged[i]);
  }
  printf("\n");
}

int main()
{
  int arr1[] = {1, 3, 4};
  int arr2[] = {2, 5, 6};
  mergeAndSort(arr1, sizeof(arr1) / sizeof(arr1[0]), arr2, sizeof(arr2) / sizeof(arr2[0]));
  return 0;
}